﻿using System;
using System.Collections.Generic;
using System.Text;

namespace taigu
{
    /*
     文件名:ResData
     创建时间:2021-10-15
     作者:gavin
     功能：全局数据返回对像
     */
    /// <summary>
    /// 系统消息返回枚举
    /// </summary>
    /// <typeparam name="T">数据类型</typeparam>
    public class ResData<T>
    {
        /// <summary>
        /// 数据状态
        /// </summary>
        public ResStatus Status { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        public string Msg { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public T Info { get; set; }

        /// <summary>
        /// 返回失败信息
        /// </summary>
        /// <param name="t"></param>
        /// <param name="msg"></param>
        /// <param name="resStatus"></param>
        /// <returns></returns>
        public static ResData<T> Error(T t, Exception ex, ResStatus resStatus = ResStatus.修改失败)
        {
            return new ResData<T>() { Info = t, Msg = ex?.Message, Status = resStatus };
        }
    }
}
